package ua.yandex.prodcons.threads;

import java.util.*;

public class Run {

    public static void main(String[] args) {
        int num = 20;
        CircularBuffer que = new CircularBuffer(num);
        int ms1 = 500000;
        int ms2 = 750000;
        long begin = System.currentTimeMillis();
        Thread prod1 = new Thread(new Producer(que, ms1));
        Thread prod2 = new Thread(new Producer(que, ms1));
        Thread prod3 = new Thread(new Producer(que, ms1));
        Thread cons1 = new Thread(new Consumer(que, ms2));
        Thread cons2 = new Thread(new Consumer(que, ms2));
        prod1.start();
        prod2.start();
        prod3.start();
        cons1.start();
        cons2.start();
        try {
            cons1.join();
            cons2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println(end - begin);
    }
}
